<template>
	<view class="container-page">
		<!-- #ifdef APP -->
		<u-navbar title="头像相似度" :autoBack="true" :placeholder="true">></u-navbar>
		<!-- #endif -->
		<view class="container">
			<view class="upload-section">
				<!-- <uploadImage @uploadSuccess='uploadSuccess' name="image" :maxCount='1' width="240rpx" height="240rpx">
				</uploadImage> -->
				<u--image :src="$OssUrl(auth_avatar)" width="80px" height="120px" mode="widthFix" radius="5"></u--image>

				<!-- <view class="upload-tip">与账号性别不匹配</view> -->
			</view>
			<view class="avatar-similarity">
				头像与本人相似度 <text style="color: #F169F6;">{{Confidence}}%</text>
			</view>
			<view class="notice">
				<!-- <view class="notice-title">注意事项:</view> -->
				<view class="notice-items">
					<view class="notice-item"> 1.相似度是指头像与扫脸照片相似度 </view>
					<view class="notice-item"> 2.相似度越高，享受的推荐值越高，受欢迎程度越高 </view>
					<view class="notice-item"> 3.相似度>75%为正常结果，低于70%无法通过认证 </view>
					<view class="notice-item"> 4.过度的P图和素颜可能会导致相似度降低，建议妆后 认证 </view>
					<view class="notice-item"> 5.相似度结果为AI判定，无人工干预</view>
				</view>
			</view>
			<view class="submit-section">
				<button class="submit-btn" @click="handleSubmit">下一步</button>
				<!-- <view class="warning-text">
					<text>重新扫脸</text>
				</view> -->
			</view>
		</view>
		<view style="height: 20rpx;"></view>
		<u-popup :show="show" round="24rpx" mode="center" :safeAreaInsetBottom="false">
			<view class="contentBox" v-if="userInfo">
				<!-- <image class="popup-close" src="../../static/common/icon_close.png" @click="cancelInfo" /> -->
				<image src="../../static/common/icon_improve.png" class="popup-image"></image>
				<view class="popup-title">已提交审核</view>
				<view class="popup-tips">
					前往补全基础信息，可以提高认证通过率和更多曝光哦~
				</view>
				<view class="button-group">
					<view class="button1" @click="completeInfo">
						前往补全资料
					</view>
					<view class="popup-tips" @click="cancelInfo">下次再说</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import uploadImage from '@/components/UploadImage.vue';
	export default {
		data() {
			return {
				show: false,
				userInfo: null,
				auth_avatar: '',
				real_avater: '',
				Confidence: 0,
			}
		},
		components: {
			uploadImage: uploadImage
		},
		onLoad(options) {
			this.Confidence = options.Confidence
			this.auth_avatar = options.auth_avatar
			this.real_avater = options.real_avater
			this.getUserInfo()
		},
		methods: {
			getCamera() {

			},
			getUserInfo() {
				this.$Api['user'].getUserInfo().then(res => {
					this.userInfo = res.data
				})
			},
			handleSubmit() {
				if (this.real_avater == '') {
					return this.$Toast('请选择真人图片')
				}
				this.$Api['user'].submitUserAuth({
					avatar: this.userInfo.avatar,
					auth_avatar: this.auth_avatar,
					real_avater: this.real_avater,
					auth_xsd:this.Confidence
				}).then(res => {
					this.$Toast('提交成功请等待审核')
					setTimeout(() => {
						this.submitSuccess()
					}, 2000)
				})
			},
			cancelInfo() {
				this.show = true
				uni.navigateBack({
					delta: 1
				})
			},
			completeInfo() {
				this.show = false
				uni.redirectTo({
					url: '/pages/mine/user-info'
				})
			},
			//提交成功
			submitSuccess() {
				if (this.userInfo.images.length == 0) {
					this.show = true
					// uni.showModal({
					// 	content: "资料未完善是否去完善",
					// 	success(res) {
					// 		if (res.confirm) {
					// 			
					// 		} else {
					// 			
					// 		}
					// 	},
					// })
				} else {
					uni.navigateBack({
						delta: 1
					})
				}
			},
			uploadSuccess(e) {
				this.real_avater = e.fileList
			}
		}
	}
</script>
<style lang="scss" scoped>
	.container-page {
		width: 100%;
		min-height: 100vh;
		background-color: #f7f8fa;
		position: relative;

		.container {
			min-height: 80vh;
			margin: 20rpx;
			padding: 38rpx 40rpx 38rpx;
			box-shadow: 0rpx 4rpx 32rpx 0rpx #FFF0FD;
			border-radius: 32rpx;
			background: linear-gradient(180deg, #FFDAF5 0%, #FFFFFF 5%);

			.avatar-similarity {
				font-size: 36rpx;
				color: #323334;
				font-weight: 600;
				margin-bottom: 24rpx;
			}

			.notice {
				padding: 30rpx;
				margin-bottom: 40rpx;
				background: #FFF2FD;
				border-radius: 32rpx;

				.notice-title {
					font-size: 30rpx;
					color: #F169F6;
					margin-bottom: 20rpx;
				}

				.notice-items {
					font-size: 24rpx;
					color: #9A9A9A;

					.notice-item {

						line-height: 44rpx;
					}
				}
			}

			.upload-section {
				background-color: #FFFFFF;
				border-radius: 16rpx;
				padding: 30rpx 0 42rpx;

				.upload-title {
					font-size: 16px;
					color: #333333;
					margin-bottom: 30rpx;
				}


				.upload-tip {
					font-size: 14px;
					color: #FF6B6B;
					margin-top: 20rpx;
				}
			}

			.submit-section {
				margin: 102rpx auto 0;

				.submit-btn {
					width: 628rpx;
					height: 88rpx;
					font-weight: bold;
					font-size: 30rpx;
					color: #FFFFFF;
					text-align: center;
					line-height: 88rpx;
					background: linear-gradient(135deg, #FE93BF 0%, #A27AFF 100%);
					box-shadow: 0rpx 4rpx 10rpx 0rpx #FDC4FF;
					border-radius: 44rpx;
				}
			}

			.warning-text {
				display: flex;
				justify-content: center;
				font-size: 12px;
				color: #FF6B6B;
				line-height: 32rpx;
				margin-top: 20rpx;

				.warning-text text {
					margin-left: 8rpx;
				}
			}
		}
	}

	.contentBox {
		width: 90vw;
		min-height: 440rpx;
		box-sizing: border-box;
		padding: 38rpx 44rpx 82rpx;
		box-shadow: 0rpx 4rpx 32rpx 0rpx #FFF0FD;
		border-radius: 32rpx;
		background: linear-gradient(180deg, #FFDAF5 0%, #FFFFFF 20%);
		position: relative;
		text-align: center;

		.popup-close {
			position: absolute;
			right: 0;
			top: -120rpx;
			width: 88rpx;
			height: 88rpx;
		}

		.popup-image {
			margin-top: 60rpx;
			width: 412rpx;
			height: 316rpx;
		}

		.popup-title {
			font-weight: 600;
			font-size: 34rpx;
			color: #323334;
			text-align: center;
		}


		.popup-tips {
			margin-top: 18rpx;
			font-size: 28rpx;
			color: #9A9A9A;
		}

		.button-group {
			margin-top: 68rpx;

			.title {
				display: block;
				color: #ffffff;
				text-decoration: none;
			}

			.button1 {
				display: flex;
				align-items: center;
				justify-content: center;
				margin: 0 auto;
				width: 600rpx;
				height: 88rpx;
				font-weight: bold;
				font-size: 30rpx;
				color: #FFFFFF;
				text-align: center;
				line-height: 88rpx;
				background: linear-gradient(135deg, #FE93BF 0%, #A27AFF 100%);
				border-radius: 44rpx;
			}
		}
	}
</style>